$(document).ready(function(){
	base_url = document.URL.slice(0,document.URL.indexOf("index.php"));
	$(".item").mouseover(function(){
		$(this).find(".item_children").fadeIn(0);
		$(this).attr("style","background-color:#eee;border-bottom:1px dashed #9c3;");
	});
	$(".item").mouseout(function(){
		
		$(this).find(".item_children").fadeOut(0);
		$(this).attr("style","background-color:#fff;");
	});

	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/ajax/statistics/home_data",
		async: true,
		success: function(data){
			for(var i in data){
				$('.total_'+i).text(data[i]);
			}
		},
		dataType: "json"
	});//end of $.ajax
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/bbs/new_post/7/5",
		async: true,
		success: function(data){
			
			for(var i in data){
				linkUrl=base_url+"/bbs/viewtopic.php?id="+data[i].id;
				$('#new_donation').append('<li><a href='+linkUrl+'>'+'<span style="color:orange;font-size:14px;">-</span>'+data[i].subject+'</a></li>');
			}
		},
		dataType: "json"
	});//end of $.ajax
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/bbs/new_post/9/5",
		async: true,
		success: function(data){
			
			for(var i in data){
				linkUrl=base_url+"/bbs/viewtopic.php?id="+data[i].id;
				$('#new_lost').append('<li><a href='+linkUrl+'>'+'<span style="color:orange;font-size:14px;">-</span>'+data[i].subject+'</a></li>');
			}
		},
		dataType: "json"
	});//end of $.ajax
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/ajax/order/latest_delivery",
		async: true,
		success: function(data){
			for(var i in data){
				$('#new_order').append('<li><span style="color:orange;font-size:14px;">-</span>用户'+data[i].customer_name+'的订单已于'+data[i].year+'年'+data[i].month+'月'+data[i].day+'日确认</a></li>');
			}
		},
		dataType: "json"
	});//end of $.ajax
	
	
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/bbs/new_post/11/5",
		async: true,
		success: function(data){
			
			for(var i in data){
				linkUrl=base_url+"/bbs/viewtopic.php?id="+data[i].id;
				$('#top_volunteer').append('<li><a href='+linkUrl+'>'+'<span style="color:orange;font-size:14px;">-</span>'+data[i].subject+'</a></li>');
			}
		},
		dataType: "json"
	});//end of $.ajax
	
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/bbs/new_post/12/5",
		async: true,
		success: function(data){
			
			for(var i in data){
				linkUrl=base_url+"/bbs/viewtopic.php?id="+data[i].id;
				$('#top_provider').append('<li><a href='+linkUrl+'>'+'<span style="color:orange;font-size:14px;">-</span>'+data[i].subject+'</a></li>');
			}
		},
		dataType: "json"
	});//end of $.ajax
	
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/bbs/new_post/10/5",
		async: true,
		success: function(data){
			
			for(var i in data){
				linkUrl=base_url+"/bbs/viewtopic.php?id="+data[i].id;
				$('#top_article').append('<li><a href='+linkUrl+'>'+'<span style="color:orange;font-size:14px;">-</span>'+data[i].subject+'</a></li>');
			}
		},
		dataType: "json"
	});//end of $.ajax
	
	
	//首页商品动态slider
	$.ajax({
		type: 'GET',
		url: base_url+"/index.jsp/imagee/",
		async: true,
		success: function(data){
			for(var i in data){
				$('.product_news').find('ul').append('<li><a href="'+data[i]['href']+'"><img src="'+data[i]['src']+'"/></a></li>');
			}
			$('.product_news_slider_div').bjqs({
		          'animation' : 'slide',
		          'width' : 500,
		          'height' : 200,
				  'showMarkers' : true,
				  'showControls' : false,
				  'centerMarkers' : false

		    });	
		},
		dataType: "json"
	});//end of $.ajax

	//首页公益组织slider
	$.ajax({
		type: 'GET',
		url: base_url+"/index.php/bbs/slider_link/26",
		async: true,
		success: function(data){
			for(var i in data){
				$('.club_news').find('ul').append('<li><a href="'+data[i]['href']+'"><img src="'+data[i]['src']+'"/></a></li>');
			}
			$('.club_news_slider_div').bjqs({
		          'animation' : 'fade',
		          'width' : 500,
		          'height' : 100,
				  'showMarkers' : true,
				  'showControls' : false,
				  'centerMarkers' : false

		    });
		},
		dataType: "json"
	});//end of $.ajax
});

//滚动插件
(function($){
$.fn.extend({
		Scroll:function(opt,callback){
				//参数初始化
				if(!opt) var opt={};
				var _this=this.eq(0).find("ul:first");
				_this.find("li").each(function(index){
					//alert(index+":"+$(this).html());
				});
				var        lineH=_this.find("li:first").height(), //获取行高
						line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
						speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
						timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
				if(line==0) line=1;
				var upHeight=0-line*lineH;
				//滚动函数
				scrollUp=function(){
						_this.animate({
								marginTop:upHeight
						},speed,function(){
								for(i=1;i<=line;i++){
										_this.find("li").each(function(index){
											//alert(index+":"+$(this).text());
											if(index<4){
												$(this).appendTo(_this);
											}
											
										});
								}
								_this.css({marginTop:0});
						});
				}
				//鼠标事件绑定
				_this.hover(function(){
						clearInterval(timerID);
				},function(){
						timerID=setInterval("scrollUp()",timer);
				}).mouseout();
		}        
})
})(jQuery);

$(document).ready(function(){
		$("#scrollDiv").Scroll({line:1,speed:500,timer:3000});
});